package com.my.objects;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;

/**
 * @description:
 * @author: marshal
 * @date: 2021-08-24 2:36 PM
 */
public class ReadTeacher {
    public static void main(String[] args) {
        try (var ois = new ObjectInputStream(new FileInputStream("file/write_teacher.txt"))) {
            var t1 = (Teacher) ois.readObject();
            var t2 = (Teacher) ois.readObject();
            var p = (Person) ois.readObject();
            var t3 = (Teacher) ois.readObject();
            System.out.println(t1);
            System.out.println(t2);
            System.out.println(p);
            System.out.println("t1.student == t2.student ? " + (t1.getStudent() == t2.getStudent()));
            System.out.println("t1.student == p ? " + (t1.getStudent() == p));
            System.out.println("t2.student == p ? " + (t2.getStudent() == p));
            System.out.println(t3);
            System.out.println("t2 == t3 ? " + (t2 == t3));
        } catch (IOException | ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
}
